# author: axin
# date: 2021/4/19 20:04
# description:
from django.urls import path, re_path
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

from meiduo_admin.views import statistical, users, specs, images, skus, orders, permissions, group, admin

urlpatterns = [
    # 登录路由
    path('authorizations/', obtain_jwt_token),
    # 查询用户总量
    path('statistical/total_count/', statistical.UserCountView.as_view()),
    # 日增用户数量查询
    path('statistical/day_increment/', statistical.UserDayCountView.as_view()),
    # 日活用户数量查询
    path('statistical/day_active/', statistical.UserActiveCountView.as_view()),
    # 日下单查询
    path('statistical/day_orders/', statistical.UserOrderCountView.as_view()),
    # 月新增用户查询
    path('statistical/month_increment/', statistical.UserMonthCountView.as_view()),
    # 日商品访问量
    path('statistical/goods_day_views/', statistical.GoodsDayView.as_view()),
    # 查询用户，用户管理路由
    path('users/', users.UserView.as_view()),
    # 规格路由表
    path('goods/simple/', specs.SpecsView.as_view({'get': 'simple'})),
    # 图片路由表
    path('skus/simple/', images.ImageView.as_view({'get': 'simple'})),
    # sku路由
    re_path(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),
    # content_type
    path('permission/content_type/', permissions.PermissionsView.as_view({'get': 'content_type'})),
    # group/simple
    path('permission/simple/', permissions.PermissionsView.as_view({'get': 'simple'})),
    path('permission/groups/simple/', admin.AdminView.as_view({'get': 'simple'})),
]

# --------规格表路由————————————自动生成
router = DefaultRouter()
# router.register('goods/specs/', specs.SpecsView, base_name='specs')
router.register('goods/specs', specs.SpecsView, basename='specs')
# print(router.urls)
urlpatterns += router.urls

# ----------图片表路由———————————自动生成
router = DefaultRouter()
router.register('sku/images', images.ImageView, basename='images')
urlpatterns += router.urls

# ------sku路由----------自动生成
router = DefaultRouter()
router.register('skus', skus.SKUView, basename='skus')
# print(router.urls)
urlpatterns += router.urls

# ----------订单路由———————————自动生成
router = DefaultRouter()
router.register('orders', orders.OrderView, basename='orders')
urlpatterns += router.urls

# ----------权限路由———————————自动生成
router = DefaultRouter()
router.register('permission/perms', permissions.PermissionsView, basename='perms')
urlpatterns += router.urls

# ----------分组路由———————————自动生成
router = DefaultRouter()
router.register('permission/groups', group.GroupView, basename='groups')
urlpatterns += router.urls

# ----------管理员路由———————————自动生成
router = DefaultRouter()
router.register('permission/admins', admin.AdminView, basename='admins')
urlpatterns += router.urls
